package com.appleyk.query;

import com.appleyk.model.Movie;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface DepartmentQuery extends Neo4jRepository<Movie, Long> {

    /**
     * 部门 详情
     * @param departmentName departmentName
     * @return 详情
     */
    @Query("MATCH (n:Departments) WHERE n.departmentName = {departmentName} RETURN n.departmentDescription")
    String getDepartments(@Param("departmentName") String departmentName);

    /**
     * 部门 人数
     * @param departmentName departmentName
     * @return 人数
     */
    @Query("match(n:Employees)-[:work]->(m:Departments) where m.departmentName={departmentName} return count(n)")
    String getDepartmentsEmpNumber(@Param("departmentName") String departmentName);

    /**
     * 部门 有哪些人
     * @param departmentName departmentName
     * @return 有哪些人
     */
    @Query("match(n:Employees)-[:work]->(m:Departments) where m.departmentName={departmentName} return n.employeesName")
    List<String> getDepHaveEmp(@Param("departmentName") String departmentName);

    /**
     * 部门 有哪些岗位
     * @param departmentName departmentName
     * @return 有哪些人
     */
    @Query("match(n:Positions)-[:hava]->(m:Departments) where m.departmentName={departmentName} return n.positionName")
    List<String> getDepHavePosName(@Param("departmentName") String departmentName);
}
